package cn.it.shop.action;

import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.it.shop.model.Category;

@SuppressWarnings("serial")
@Controller
@Scope("prototype")
public class CategoryAction extends BaseAction<Category> {

	public String queryJoinAccount() {
		pageMap = new HashMap<String, Object>();
		List<Category> categoryList = categoryService.queryJoinAccount(
				model.getType(), page, rows);
		pageMap.put("rows", categoryList);
		long total = categoryService.getCount(model.getType());
		pageMap.put("total", total);

		return "jsonMap";
	}

	public String deleteByIds() {

		categoryService.deleteByIds(ids);
		inputStream = new ByteArrayInputStream("true".getBytes());
		return "stream";

	}

	public String query() {
		jsonList = categoryService.query();
		return "jsonList";
	}

	public void save() {
		System.out.println(model);
		categoryService.save(model);
	}

	public void update() {
		System.out.println("================categoryService---->update=====");
		System.out.println(model);
		categoryService.update(model);
	}
}
